package com.example.three_hello

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View

import android.widget.Button

import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.Spinner
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity


class MainActivity : AppCompatActivity() {
    @SuppressLint("SetTextI18n")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val container=findViewById<LinearLayout>(R.id.container)
        var number=0
        val button=findViewById<Button>(R.id.button)
        val scrollView=findViewById<ScrollView>(R.id.scrollView)

        button.setOnClickListener {
            val textView= TextView(this)
            number++
            textView.text=getString(R.string.textView,number)
            textView.textSize=25f
            container.addView(textView)
            scrollView.fullScroll(View.FOCUS_DOWN)
        }


        val feature= ProgramAdviser()
        val button1=findViewById<Button>(R.id.button1)
        val textView2=findViewById<TextView>(R.id.textView2)
        val spinner=findViewById<Spinner>(R.id.spinner)
        button1.setOnClickListener {
            textView2.text=feature.getLanguage(spinner.selectedItem.toString())
        }



//        val linearLayout = LinearLayout(this)
//        linearLayout.orientation = LinearLayout.VERTICAL
//        linearLayout.setPadding(50, 100, 50, 100)
//
//        val flagImageView = ImageView(this)
//        val flagParams = ViewGroup.LayoutParams(
//            ViewGroup.LayoutParams.MATCH_PARENT,  // 宽度占满屏幕,
//            650
//        )
//        flagImageView.setLayoutParams(flagParams)
//        flagImageView.setImageResource(R.drawable.flag)
//        linearLayout.addView(flagImageView)
//
//        val textView = TextView(this)
//        val textViewParams = ViewGroup.LayoutParams(
//            ViewGroup.LayoutParams.MATCH_PARENT,
//            ViewGroup.LayoutParams.WRAP_CONTENT
//        )
//        textView.setLayoutParams(textViewParams)
//        textView.textSize = 30f
//        textView.setText(R.string.hello_world)
//        textView.setPadding(0, 50, 0, 50)
//        linearLayout.addView(textView)
//
//        val button = Button(this)
//        val buttonParams = ViewGroup.LayoutParams(
//            ViewGroup.LayoutParams.MATCH_PARENT,
//            ViewGroup.LayoutParams.WRAP_CONTENT
//        )
//        button.setLayoutParams(buttonParams)
//        button.setText(R.string.button)
//        linearLayout.addView(button)


    }
}











